//
//  MMEditorViewController.m
//  zhihuDaily
//
//  Created by li  bo on 16/6/13.
//  Copyright © 2016年 cc. All rights reserved.
//

#import "MMEditorViewController.h"
#import "MMMMEditorCell.h"
#import "MMEditorModel.h"
#import "MMEditorDetailViewController.h"
@interface MMEditorViewController ()<UITableViewDelegate,UITableViewDataSource>

/**  */
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation MMEditorViewController

static NSString * const editor_reuseid = @"editor_reuseid";

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight-64) style:UITableViewStylePlain];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([MMMMEditorCell class]) bundle:nil] forCellReuseIdentifier:editor_reuseid];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.rowHeight = 60;
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"主编";
    
    [self.view addSubview:self.tableView];
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    self.sy_header.dk_backgroundColorPicker = DKColorPickerWithKey(NAV);
    self.tableView.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
   // self.sy_header.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
    self.sy_titleLabel.dk_textColorPicker = DKColorPickerWithKey(TEXT);
}


- (void)setEditorArray:(NSArray *)editorArray
{
    _editorArray = editorArray;


}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.editorArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MMMMEditorCell *cell = [tableView dequeueReusableCellWithIdentifier:editor_reuseid forIndexPath:indexPath];
    cell.backgroundColor = [UIColor clearColor];
    MMEditorModel *editorModel = self.editorArray[indexPath.row];
    cell.editorModel = editorModel;
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    MMEditorDetailViewController *edVc = [[MMEditorDetailViewController alloc] init];

    MMEditorModel *model = self.editorArray[indexPath.row];

    edVc.editorModel = model;

    [self.navigationController pushViewController:edVc animated:YES];
    
    
}
@end
